const { Types } = require("mongoose");
const mongoose = require("./db");

let userSchema = new mongoose.Schema({
  name: String,
  password: String,
});
let userlist = new mongoose.Schema({
  username: String,
  password: String,
  path: String,
  sum: Number,
  shijian: String,
  num: Number,
  price: Number,
  sjh: String,
  brthday: String,
  sex: String,
  nicheng: String,
  dizhi: String,
  dian: String,
  cate: {
    type: mongoose.Schema.Types.ObjectId,
    ref: "cate",
  },
});
let catelist = new mongoose.Schema({
  path: String,
  name: String,
  num: String,
  sum: Number,
});

let stulist = new mongoose.Schema({
  path: String,
  name: String,
  sum: Number,
  num: String,
});

let shoulist = new mongoose.Schema({
  path: String,
  name: String,
  text: String,
  zhe: String,
  price: Number,
});

let leilist = new mongoose.Schema({
  path: String,
  name: String,
});

const orderSchema = new mongoose.Schema({
  orderId: { type: String, required: true, unique: true },
  productId: { type: String, required: true },
  userId: { type: String, required: true },
  status: { type: String, default: "pending" },
  // 其他订单相关的字段可以根据实际情况添加
});

const useelist = new mongoose.Schema({
  alipayUserId: String,
  name: String,
});

let a = new mongoose.Schema(
  {
    title: String,
  },
  { versionKey: false }
);

let b = mongoose.model("catess", a, "catess");

let c = new mongoose.Schema(
  {
    name: String,
    time: String,
    img: String,
    title: String,
    read: Number,
    pid: {
      type: mongoose.Types.ObjectId,
      ref: "cate",
    },
    imgg: Array,
  },
  { versionKey: false }
);

let d = mongoose.model("com", c, "com");

let e = new mongoose.Schema(
  {
    img: String,
    name: String,
    title: String,
    read: Number,
    imggg: Array,
    zh: Number,
    fs: Number,
    zan: Number,
    guan: Number,
    ping: Array,
  },
  { versionKey: false }
);

let f = mongoose.model("xiang", e, "xiang");

let g = new mongoose.Schema(
  {
    title: String,
    time: String,
    img: String,
    zan: Number,
    read: String,
    context: String,
    ping: Array,
    pid: {
      type: mongoose.Types.ObjectId,
      ref: "xiang",
    },
  },
  { versionKey: false }
);

let ChatSchema = new mongoose.Schema({
  msg: String,
  state: String,
  name: String,
});

let ChatModel = mongoose.model("chat", ChatSchema, "chat");

let ChatsSchema = new mongoose.Schema({
  msg: String,
  state: String,
  name: String,
});
let DingDanLieBiaoSchema = new mongoose.Schema({
  shop: String, //店铺名称
  state: String, //订单状态
  title: String, //商品名称
  norms: String,  //商品规格
  price: Number, //商品价格
  num: Number, //商品数量
})
let StudentSchema = new mongoose.Schema({
  name: String,
  path: String,
  sum: Number,
  num:String,
})
let StudenModel = mongoose.model('stus', StudentSchema, 'stus')
let CateSchema = new mongoose.Schema({
  name: String,
  path: String,
  zui: Number,
  price:String,
})
let CateModel = mongoose.model('cates', CateSchema, 'cates')
let UserSchema = new mongoose.Schema({
  name: String,
  path: String,
  sum: Number,
  num:Number,
  shijian:String,
  price:String,
})
let UserModel = mongoose.model('useres', UserSchema, 'useres')
let DingDanLieBiaoMedol = mongoose.model("dingdanliebiao", DingDanLieBiaoSchema, 'dingdanliebiao');

let ChatsModel = mongoose.model("chats", ChatsSchema, "chats");

let h = mongoose.model("wen", g, "wen");
let shou = mongoose.model("shou", shoulist);

let lei = mongoose.model("lei", leilist);

let Order = mongoose.model("Order", orderSchema);

let usee = mongoose.model("usee", useelist);

let user = mongoose.model("user", userlist);

let stu = mongoose.model("stu", stulist);

let cate = mongoose.model("cate", catelist);
let userModel = mongoose.model("users", userSchema, "user");
module.exports = {
  userModel,
  user,
  stu,
  cate,
  shou,
  lei,
  Order,
  usee,
  d,
  b,
  f,
  h,
  ChatModel,
  ChatsModel,
  DingDanLieBiaoMedol,
  StudenModel,
  CateModel,
  UserModel,
  
};
